﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace SecureCookie.Implementation.Helper
{
    /// <summary>
    /// Utility class with extension methods around the <see cref="HttpCookie"/> class.
    /// </summary>
    static class HttpCookieHelper
    {
        /// <summary>
        /// Prints everything about a <see cref="HttpCookie"/> in one string
        /// </summary>
        /// <param name="cookie">The cookie that should be printed</param>
        /// <returns>Everything about the given cookie represented in one string</returns>
        public static string ToDetailedString(this HttpCookie cookie)
        {
            var builder = new StringBuilder();
            builder.AppendFormat("{0}:[{1}],", "Name", cookie.Name);
            builder.AppendFormat("{0}:[{1}],", "Value", cookie.Value);
            builder.AppendFormat("{0}:[{1}],", "Path", cookie.Path);
            builder.AppendFormat("{0}:[{1}],", "Secure", cookie.Secure);
            builder.AppendFormat("{0}:[{1}],", "HttpOnly", cookie.HttpOnly);
            builder.AppendFormat("{0}:[{1}],", "Domain", cookie.Domain);
            builder.AppendFormat("{0}:[{1}]", "Expires", cookie.Expires);
            return builder.ToString();
        }
    }
}

